home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2003 November A
/
PCWK1103A.iso
/
Adobe After Effects 6.0 tryout
/
MM5.Cab
/
F3698_save_and_increment.jsx.304FA6F7_2783_11D4_8520_00C04F602FD3
< prev
next >
Wrap
Text File
|
2003-07-18
|
1KB
|
34 lines
if (!app.project.file) {
alert ("This project must be saved before running this script.");
} else {
var currFile = app.project.file;
var currFileName = currFile.name;
var extPos = currFileName.lastIndexOf(".");
var ext = "";
if (extPos != -1) {
ext = currFileName.substring(extPos, currFileName.length);
currFileName = currFileName.substring(0, extPos);
}
var incrementer = 0;
if (currFileName.charAt(currFileName.length -4) == "_") {
//Assume the incrementer has run before if underscore is the fourth character from the end.
//This is the case for files with 3 digit extensions.
incrementer = currFileName.substring(currFileName.length - 3, currFileName.length);
currFileName = currFileName.substring(0, currFileName.length -4);
}
incrementer++;
var istring = incrementer + "";
if( (incrementer / 10) < 1.0) {
istring = "0" + istring;
}
if( (incrementer / 100) < 1.0) {
istring = "0" + istring;
}
var newFile = File(currFile.path + "/" + currFileName + "_" + istring + ext);
alert(newFile.fsName);
app.project.save(newFile);
}